<!--版面搜索-->
<script lang="ts" setup>
import {ref} from "vue";
import {useRoute} from "vue-router";
import {useForumStore} from "../../store/ForumStore.ts";
import ForumIconName from "../../components/entrance/ForumIconName.vue";
import type {ForumSearchResult} from "../../network/types/Forum.ts";

const route = useRoute();
const forumStore = useForumStore();
const keywords = ref("")
const page = ref<number>()
const loading = ref(false)

const data = ref<ForumSearchResult[]>()

const search = () => {
  if (!keywords.value) return
  forumStore.search(keywords.value, page.value).then(res => {
    console.log(res)
    data.value = res
    loading.value = false
  }).catch(r => {
    console.error(r)
    loading.value = false
  })
}

</script>

<template>
  <div v-loading="loading" class="route-root">
    <el-input v-model="keywords" placeholder="请输入关键字,回车确认" @keyup.enter="search"/>
    <div v-if="data" class="forum-entrances">
      <forum-icon-name v-for="forum in data" :fid="forum.fid" :name="forum.name" :stid="forum.stid"/>
    </div>
  </div>
</template>

<style scoped>

</style>